home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 20.8 KB | 655 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWEvent.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWEVENT_H
- #define FWEVENT_H
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- #ifndef FWRUNTYP_H
- #include "FWRunTyp.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(_INC_WINDOWS)
- #include <windows.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward class declarations
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPoint;
- class FW_CLASS_ATTR ODFrame;
- class FW_CLASS_ATTR ODFacet;
- class FW_CLASS_ATTR FW_CEmbeddedMouseEvent;
- class FW_CLASS_ATTR FW_CMapping;
-
- //========================================================================================
- // Type definitions
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- typedef long FW_PlatformEventTime;
- #endif
-
- #ifdef FW_BUILD_WIN
- typedef DWORD FW_PlatformEventTime;
- #endif
-
- //========================================================================================
- // CLASS FW_CSystemEvent
- //========================================================================================
- class FW_CLASS_ATTR FW_CSystemEvent
- {
- public:
- FW_DECLARE_CLASS
-
- virtual ~FW_CSystemEvent();
-
- ODEventData* GetPlatformEvent();
- unsigned long GetMessage() const;
- FW_PlatformEventTime GetTime() const;
- unsigned long GetModifiers() const;
- ODPlatformWindow GetPlatformWindow() const;
-
- protected:
- FW_CSystemEvent(Environment* ev, ODPlatformWindow theWindow, FW_PlatformEventTime time);
- FW_CSystemEvent(Environment* ev, ODEventData* theEvent);
-
- FW_CSystemEvent(Environment* ev, const FW_CSystemEvent& other);
-
- ODEventData fEvent;
- ODPlatformWindow fPlatformWindow;
- };
-
- //========================================================================================
- // CLASS FW_CNullEvent
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CNullEvent : public FW_CSystemEvent
- {
- public:
- FW_DECLARE_CLASS
-
- FW_CNullEvent(Environment* ev, ODEventData* theEvent);
- FW_CNullEvent(Environment* ev, ODPlatformWindow theWindow, FW_PlatformEventTime time);
-
- FW_CNullEvent(Environment* ev, const FW_CNullEvent& other);
- virtual ~FW_CNullEvent();
- };
-
- #ifdef FW_BUILD_MAC
- //========================================================================================
- // CLASS FW_CMacWindowEvent
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CMacWindowEvent : public FW_CSystemEvent
- {
- public:
- FW_DECLARE_CLASS
-
- FW_CMacWindowEvent(Environment* ev, ODEventData* theEvent);
- virtual ~FW_CMacWindowEvent();
- };
- #endif
-
- //========================================================================================
- // CLASS FW_CMouseEvent
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CMouseEvent : public FW_CSystemEvent
- {
- public:
- FW_DECLARE_CLASS
-
- enum ButtonState
- {
- kMouseButtonDown, kMouseButtonUp
- };
-
- enum WhichButton
- {
- kLeftMouseButton, kMiddleMouseButton, kRightMouseButton
- };
-
- enum ECoordinates
- {
- kScreen, kWindow, kFrame
- };
-
- static const short kEmpty;
- static const short kExtend;
- static const short kItem;
- static const short kCopy;
- static const short kControl;
-
- FW_CMouseEvent(Environment* ev, ODEventData* theEvent, ODFacet* theFacet, ButtonState theState, short numOfClicks = 1);
- FW_CMouseEvent(Environment* ev, ODFacet* theFacet,
- ButtonState theState,
- WhichButton initialButton,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- const FW_CPoint& where,
- unsigned short modifiers,
- short numOfClicks = 1);
- FW_CMouseEvent(Environment* ev, const FW_CEmbeddedMouseEvent& embeddedEvent);
-
- FW_CMouseEvent(Environment* ev, const FW_CMouseEvent& other);
- virtual ~FW_CMouseEvent();
-
-
- ODFacet* GetFacet(Environment* ev) const;
- ButtonState GetButtonState(Environment* ev) const;
- WhichButton GetInitialButtonPressed(Environment* ev) const;
- short GetNumberOfClicks(Environment* ev) const;
- unsigned short GetButtonModifiers(Environment* ev) const;
-
- // Position
- FW_CPoint GetLogicalMousePosition(Environment* ev,
- const FW_CMapping& mapping) const;
- FW_CPoint GetMousePosition(Environment* ev,
- ECoordinates coordinate) const;
-
- // Buttons Pressed
- FW_Boolean IsLeftButtonPressed(Environment* ev) const;
- FW_Boolean IsMiddleButtonPressed(Environment* ev) const;
- FW_Boolean IsRightButtonPressed(Environment* ev) const;
-
- // Modifiers
- FW_Boolean IsExtendModifier(Environment* ev) const;
- FW_Boolean IsItemModifier(Environment* ev) const;
- FW_Boolean IsCopyModifier(Environment* ev) const;
- FW_Boolean IsControlKeyModifier(Environment* ev) const; // No semantic equivalent on the Mac
-
- void ClearExtendModifier(Environment* ev);
- void ClearItemModifier(Environment* ev);
- void ClearCopyModifier(Environment* ev);
- void ClearControlKeyModifier(Environment* ev);
-
- // Utility
- FW_Boolean WaitUntilMouseMoved(Environment* ev) const;
-
- protected:
- ODFacet* fFacet;
- ButtonState fButtonState;
- WhichButton fWhichButton;
- short fNumberOfClicks;
- };
-
- //========================================================================================
- // CLASS FW_CEmbeddedMouseEvent
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CEmbeddedMouseEvent : public FW_CMouseEvent
- {
- public:
- FW_DECLARE_CLASS
-
- FW_CEmbeddedMouseEvent(Environment* ev, ODEventData* theEvent,
- ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- ButtonState theState,
- short numOfClicks = 1);
-
- FW_CEmbeddedMouseEvent(Environment* ev, ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- ButtonState theState,
- WhichButton initialButton,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- const FW_CPoint& where,
- unsigned short modifiers,
- short numOfClicks = 1);
-
- FW_CEmbeddedMouseEvent(Environment* ev, const FW_CEmbeddedMouseEvent& other);
- virtual ~FW_CEmbeddedMouseEvent();
-
- ODFrame* GetEmbeddedFrame(Environment* ev) const;
- ODFacet* GetEmbeddedFacet(Environment* ev) const;
-
- private:
- ODFrame* fEmbeddedFrame;
- ODFacet* fEmbeddedFacet;
- };
-
- //========================================================================================
- // CLASS FW_CBorderMouseEvent
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CBorderMouseEvent : public FW_CMouseEvent
- {
- public:
- FW_DECLARE_CLASS
-
- FW_CBorderMouseEvent(Environment* ev, ODEventData* theEvent,
- ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- ButtonState theState,
- short numOfClicks = 1);
-
- FW_CBorderMouseEvent(Environment* ev, ODFacet* theFacet,
- ODFrame* theEmbeddedFrame,
- ODFacet* theEmbeddedFacet,
- ButtonState theState,
- WhichButton initialButton,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- const FW_CPoint& where,
- unsigned short modifiers,
- short numOfClicks = 1);
-
- FW_CBorderMouseEvent(Environment* ev, const FW_CBorderMouseEvent& other);
- virtual ~FW_CBorderMouseEvent();
-
- ODFrame* GetEmbeddedFrame(Environment* ev) const;
- ODFacet* GetEmbeddedFacet(Environment* ev) const;
-
- private:
- ODFrame* fEmbeddedFrame;
- ODFacet* fEmbeddedFacet;
- };
-
- //========================================================================================
- // CLASS FW_CVirtualKeyEvent
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CVirtualKeyEvent : public FW_CSystemEvent
- {
- public:
- FW_DECLARE_CLASS
-
- enum KeyboardState
- {
- kKeyDown, kKeyUp
- };
-
- FW_CVirtualKeyEvent(Environment* ev, ODEventData* theEvent, KeyboardState theKeyboardState, unsigned short repeatCount = 0);
- FW_CVirtualKeyEvent(Environment* ev, KeyboardState theKeyboardState,
- short keyCode,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- unsigned short repeatCount = 0);
-
- FW_CVirtualKeyEvent(Environment* ev, const FW_CVirtualKeyEvent& other);
- virtual~ FW_CVirtualKeyEvent();
-
- KeyboardState GetKeyboardState(Environment* ev) const;
- FW_Boolean IsRepeating(Environment* ev) const;
- unsigned short GetRepeatCount(Environment* ev) const;
- short GetKeyCode(Environment* ev) const;
-
- private:
- KeyboardState fKeyboardState;
- unsigned short fRepeatCount;
- };
-
-
- //========================================================================================
- // CLASS FW_CCharKeyEvent
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CCharKeyEvent : public FW_CSystemEvent
- {
- public:
- FW_DECLARE_CLASS
-
- FW_CCharKeyEvent(Environment* ev, ODEventData* theEvent, unsigned short repeatCount = 0);
- FW_CCharKeyEvent(Environment* ev, char keyChar,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when,
- unsigned short repeatCount = 0);
-
- FW_CCharKeyEvent(Environment* ev, const FW_CCharKeyEvent& other);
- virtual~ FW_CCharKeyEvent();
-
- FW_Boolean IsRepeating(Environment* ev) const;
- unsigned short GetRepeatCount(Environment* ev) const;
- char GetChar(Environment* ev) const;
-
- private:
- unsigned short fRepeatCount;
- };
-
- //========================================================================================
- // CLASS FW_CSuspendResumeEvent
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CSuspendResumeEvent : public FW_CSystemEvent
- {
- public:
- FW_DECLARE_CLASS
-
- FW_CSuspendResumeEvent(Environment* ev, ODEventData* theEvent, ODFacet* facet, FW_Boolean isGoingToBackground);
- FW_CSuspendResumeEvent(Environment* ev, const FW_CSuspendResumeEvent& other);
- virtual~ FW_CSuspendResumeEvent();
-
- FW_Boolean IsGoingToBackground(Environment* ev) const;
- ODFacet* GetFacet(Environment* ev) const;
-
- private:
- FW_Boolean fIsGoingToBackground;
- ODFacet* fFacet;
- };
-
- //========================================================================================
- // CLASS FW_CActivateEvent
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CActivateEvent : public FW_CSystemEvent
- {
- public:
- FW_DECLARE_CLASS
-
- FW_CActivateEvent(Environment* ev, ODEventData* theEvent, ODFacet* facet, FW_Boolean theState);
- FW_CActivateEvent(Environment* ev, ODFacet* facet,
- FW_Boolean theState,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when);
-
- FW_CActivateEvent(Environment* ev, const FW_CActivateEvent& other);
- virtual~ FW_CActivateEvent();
-
- FW_Boolean IsActivating(Environment* ev) const;
- ODFacet* GetFacet(Environment* ev) const;
-
- private:
- FW_Boolean fActivationState;
- ODFacet* fFacet;
- };
-
- //========================================================================================
- // CLASS FW_CMenuEvent
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CMenuEvent : public FW_CSystemEvent
- {
- public:
- FW_DECLARE_CLASS
-
- FW_CMenuEvent(Environment* ev, ODEventData* theEvent, ODCommandID theCommandID);
- FW_CMenuEvent(Environment* ev, ODCommandID theCommandID,
- ODPlatformWindow theWindow,
- FW_PlatformEventTime when);
-
- FW_CMenuEvent(Environment* ev, const FW_CMenuEvent& other);
- virtual~ FW_CMenuEvent();
-
- ODCommandID GetCommandID(Environment* ev) const;
-
- private:
- ODCommandID fCommandID;
- };
-
- //========================================================================================
- // inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::GetPlatformEvent
- //----------------------------------------------------------------------------------------
- inline ODEventData* FW_CSystemEvent::GetPlatformEvent()
- {
- return &fEvent;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::GetMessage
- //----------------------------------------------------------------------------------------
- inline unsigned long FW_CSystemEvent::GetMessage() const
- {
- return fEvent.message;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::GetTime
- //----------------------------------------------------------------------------------------
- inline FW_PlatformEventTime FW_CSystemEvent::GetTime() const
- {
- #ifdef FW_BUILD_MAC
- return fEvent.when;
- #endif
- #ifdef FW_BUILD_WIN
- return fEvent.time;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::GetModifiers
- //----------------------------------------------------------------------------------------
- inline unsigned long FW_CSystemEvent::GetModifiers() const
- {
- #ifdef FW_BUILD_MAC
- return fEvent.modifiers;
- #endif
- #ifdef FW_BUILD_WIN
- return fEvent.wParam;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSystemEvent::GetPlatformWindow
- //----------------------------------------------------------------------------------------
- inline ODPlatformWindow FW_CSystemEvent::GetPlatformWindow() const
- {
- return fPlatformWindow;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::GetFacet
- //----------------------------------------------------------------------------------------
- inline ODFacet* FW_CMouseEvent::GetFacet(Environment* ev) const
- {
- return fFacet;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::GetButtonState
- //----------------------------------------------------------------------------------------
- inline FW_CMouseEvent::ButtonState FW_CMouseEvent::GetButtonState(Environment* ev) const
- {
- return fButtonState;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::GetInitialButtonPressed
- //----------------------------------------------------------------------------------------
- inline FW_CMouseEvent::WhichButton FW_CMouseEvent::GetInitialButtonPressed(Environment* ev) const
- {
- return fWhichButton;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::GetNumberOfClicks
- //----------------------------------------------------------------------------------------
- inline short FW_CMouseEvent::GetNumberOfClicks(Environment* ev) const
- {
- return fNumberOfClicks;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::ClearExtendModifier
- //----------------------------------------------------------------------------------------
- inline void FW_CMouseEvent::ClearExtendModifier(Environment* ev)
- {
- #ifdef FW_BUILD_MAC
- fEvent.modifiers -= shiftKey;
- #endif
- #ifdef FW_BUILD_WIN
- fEvent.wParam -= MK_SHIFT;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::ClearItemModifier
- //----------------------------------------------------------------------------------------
- inline void FW_CMouseEvent::ClearItemModifier(Environment* ev)
- {
- #ifdef FW_BUILD_MAC
- fEvent.modifiers -= cmdKey;
- #endif
- #ifdef FW_BUILD_WIN
- fEvent.wParam -= MK_CONTROL;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::ClearCopyModifier
- //----------------------------------------------------------------------------------------
- inline void FW_CMouseEvent::ClearCopyModifier(Environment* ev)
- {
- #ifdef FW_BUILD_MAC
- fEvent.modifiers -= optionKey;
- #endif
- #ifdef FW_BUILD_WIN
- fEvent.wParam -= MK_CONTROL;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::ClearControlKeyModifier
- //----------------------------------------------------------------------------------------
- inline void FW_CMouseEvent::ClearControlKeyModifier(Environment* ev)
- {
- #ifdef FW_BUILD_MAC
- fEvent.modifiers -= controlKey;
- #endif
- #ifdef FW_BUILD_WIN
- fEvent.wParam -= MK_CONTROL;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::IsCopyModifier
- //----------------------------------------------------------------------------------------
- inline FW_Boolean FW_CMouseEvent::IsCopyModifier(Environment* ev) const
- {
- #ifdef FW_BUILD_MAC
- return (fEvent.modifiers & optionKey) != 0;
- #endif
- #ifdef FW_BUILD_WIN
- return (fEvent.wParam & MK_CONTROL) != 0;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMouseEvent::IsControlKeyModifier
- //----------------------------------------------------------------------------------------
- inline FW_Boolean FW_CMouseEvent::IsControlKeyModifier(Environment* ev) const
- {
- #ifdef FW_BUILD_MAC
- return (fEvent.modifiers & controlKey) != 0;
- #endif
- #ifdef FW_BUILD_WIN
- return (fEvent.wParam & MK_CONTROL) != 0;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::GetKeyboardState
- //----------------------------------------------------------------------------------------
- inline FW_CVirtualKeyEvent::KeyboardState FW_CVirtualKeyEvent::GetKeyboardState(Environment* ev) const
- {
- return fKeyboardState;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::IsRepeating
- //----------------------------------------------------------------------------------------
- inline FW_Boolean FW_CVirtualKeyEvent::IsRepeating(Environment* ev) const
- {
- return (fRepeatCount > 0);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CVirtualKeyEvent::GetRepeatCount
- //----------------------------------------------------------------------------------------
- inline unsigned short FW_CVirtualKeyEvent::GetRepeatCount(Environment* ev) const
- {
- return fRepeatCount;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::IsRepeating
- //----------------------------------------------------------------------------------------
- inline FW_Boolean FW_CCharKeyEvent::IsRepeating(Environment* ev) const
- {
- return (fRepeatCount > 0);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CCharKeyEvent::GetRepeatCount
- //----------------------------------------------------------------------------------------
- inline unsigned short FW_CCharKeyEvent::GetRepeatCount(Environment* ev) const
- {
- return fRepeatCount;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CActivateEvent::IsActivating
- //----------------------------------------------------------------------------------------
- inline FW_Boolean FW_CActivateEvent::IsActivating(Environment* ev) const
- {
- return fActivationState;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CActivateEvent::GetFacet
- //----------------------------------------------------------------------------------------
- inline ODFacet* FW_CActivateEvent::GetFacet(Environment* ev) const
- {
- return fFacet;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuspendResumeEvent::IsGoingToBackground
- //----------------------------------------------------------------------------------------
- inline FW_Boolean FW_CSuspendResumeEvent::IsGoingToBackground(Environment* ev) const
- {
- return fIsGoingToBackground;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSuspendResumeEvent::GetFacet
- //----------------------------------------------------------------------------------------
- inline ODFacet* FW_CSuspendResumeEvent::GetFacet(Environment* ev) const
- {
- return fFacet;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuEvent::GetCommandID
- //----------------------------------------------------------------------------------------
- inline ODCommandID FW_CMenuEvent::GetCommandID(Environment* ev) const
- {
- return fCommandID;
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-
-
-